package com.example.student.Servicelmpl;

import com.example.student.Repository.StudentRepository;
import com.example.student.Service.StudentService;
import com.example.student.entity.Grade;
import com.example.student.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    // 假设有一个StudentRepository用于数据库操作
    @Autowired
    private StudentRepository studentRepository;

    @Override
    public List<Student> listAll() {
        return studentRepository.findAll();
    }

    @Override
    public Student getById(Long studentId) {
        return studentRepository.findById(studentId).orElse(null);
    }

    @Override
    public List<Grade> getGrades(Long studentId) {
        // 这里需要查询成绩信息表
        return null; // 实现逻辑
    }

    @Override
    public void add(Student student) {
        studentRepository.save(student);
    }
}